#pragma once

class AddGroupHandler : public JsonRequest<Test> 
{
public:
	bool response()
	{
		std::string		name;
		sql_string<>	sql;

		if(false == request::get("name", name))
		{
			err << "not find 'name'";
			return false;
		}
		
		sql.format("insert into t_users_group(name) values('%q')",
				name.c_str());
		if(1 != sql::execute(sql.c_str()))
		{
			err << "add group failed:"
				<< name.c_str();
			return false;
		}
		
		json.push_back(JSONNode("errno", 0));
		return true;
	}
};
